<?php

require_once 'ZFBlog/Service/Recaptcha.php';

class ZFBlog_View_Helper_Recaptcha extends Zend_View_Helper_FormElement
{

    public function recaptcha(array $params, array $recaptchaOptions = null)
    {
        if (!isset($params['privateKey']) || !isset($params['publicKey'])
            || empty($params['privateKey']) || empty($params['publicKey']))
        {
            throw new Zend_View_Exception('Public and private keys must be set');
        }
        $privateKey = $params['privateKey'];
        $privateKey = $params['publicKey'];
        unset($params['privateKey'], $params['publicKey']);
        $recaptcha = new ZFBlog_Service_Recaptcha($publicKey, $privateKey);
        if (!empty($params)) {
            $recaptcha->setParams($params);
        }
        if (!is_null($recaptchaOptions)) {
            $recaptcha->setOptions($recaptchaOptions);
        }
        return $recaptcha;
    }
}